import React, { Component,Suspense } from 'react'
import { Switch,Route,Redirect } from 'react-router-dom'
export class Routerview extends Component {
  render() {
    const {routerConfig}=this.props
    return (
      <Suspense fallback="路由加载中">
        <Switch>
         {          
          routerConfig.length ? routerConfig.map((item)=>{
           return item.redirect   ?
            <Redirect to={item.redirect}></Redirect> 
            : <Route  path={item.path}
            //  component={item.component} 
            render={
              ()=>{
               return <item.component routerConfig={item.children}></item.component>

              }
            }
             ></Route> 
          
         }) :'暂无数据'   }
        
        </Switch>
      </Suspense>
    )
  }
}

export default Routerview